package com.mtl.inmigrant.shoes.entity;

import java.util.ArrayList;
import java.util.List;

public class UtilityShoesEntityApp {
	
	
	
	public static List<ReferentialPage> getReferentialPageEnfants(List<ReferentialPage> listeAllReferentialPage, String currentTask){
		
		List<ReferentialPage> listeReferentialEnfants = new ArrayList<ReferentialPage>();
		
		
		//find the referential object	 				
			for(int h=0; h < listeAllReferentialPage.size(); h++){
				ReferentialPage refPageIn;
				refPageIn = listeAllReferentialPage.get(h);
				String keyRefPage = refPageIn.getIdReferential();	 	
				
								
				if (keyRefPage.contains(currentTask)){
					listeReferentialEnfants.add(refPageIn);
				} 
				
			}
		
		
		return listeReferentialEnfants;
		
	}
	
	
	
	
public static List<TaskPage> getTaskPageEnfants(List<TaskPage> listeAllTaskPageP, String currentActivityP){
		
		List<TaskPage> listeTaskEnfants = new ArrayList<TaskPage>();
		
		
		//find the referential object	 				
			for(int h=0; h < listeAllTaskPageP.size(); h++){
				TaskPage taskPageIn;
				taskPageIn = listeAllTaskPageP.get(h);
				String keyRefPage = taskPageIn.getIdTask();	 	
				
				if (keyRefPage.contains(currentActivityP)){
					listeTaskEnfants.add(taskPageIn);
				} 				
								
			}
		
		
		return listeTaskEnfants;
		
	}
	
	
	
	   public static int countC(String wordP, Character chP)  
	    {  
	        int pos = wordP.indexOf(chP);  
	        return pos == -1 ? 0 : 1 + countC(wordP.substring(pos+1),chP);  
	    }  
		

	   public static String getStringFromAction(String infoFromPageP, String indPlaceP, int valGuion){
		   
		   String infoAction = ""; 
		   
		   int indexMyTwoPoint = infoFromPageP.indexOf(":");
		   
		   if(indPlaceP.equals("onlyId")){
			   
			   int posFirstLetterKey;
			   if(valGuion == 0){
				   
				   infoAction = infoFromPageP.substring(0, indexMyTwoPoint); //key type ie.A1
				   
			   }else if(valGuion == 1){
				   
				   posFirstLetterKey = infoFromPageP.indexOf("T"); //key type ie. T1
				   infoAction = infoFromPageP.substring(posFirstLetterKey, posFirstLetterKey + 2);
				   
			   }else if(valGuion == 2){
				   posFirstLetterKey = infoFromPageP.indexOf("R"); //key type ie. R1
				   infoAction = infoFromPageP.substring(posFirstLetterKey, posFirstLetterKey + 2);
			   }
			   
			   
		   }else if(indPlaceP.equals("onlyName")){
			   
			   infoAction = infoFromPageP.substring(indexMyTwoPoint+1, infoFromPageP.length());
		   }
		   
		   return infoAction;
		   
	   }




	

	

}
